<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="{{ '/static/style.css'|url }}">
    <title>{% block title %}Welcome{% endblock %} — FreeDict</title>
    {% block htmlheader %}{% endblock %}
  </head>
  <body>
    <header>
      <h1>{{ this.title }} — FreeDict</h1>
      <nav>
        <ul class="nav navbar-nav">
          <li{% if this._path == '/' %} class="active"{% endif %}>
            <a href="{{ '/'|url }}">{{ _("Home") }}</a></li>
          {% for href, title in [
                  ['/documentation', _('Documentation')],
                  ['/downloads', _('Downloads')],
                  ['/community', _('Community')],
                  ['/publications', _('Publications')],
                  ['/about', _('About us')] ] -%}
            <li{% if this.is_child_of(href) %} class="active"{% endif -%}>
              <a href="{{ href|url }}">{{ title }}</a></li>
          {% endfor %}
        </ul>
      </nav>
    </header>
    <main class="page">
      {% block body %}{% endblock %}
    </main>
    <footer>
      <div class="language-selection">{{ _('View this site in another language:') -}}
        {#- Collect list of alternatives -#}
        {%- set alts = {} -%}
        {% for lang in config.values['ALTERNATIVES'].values() -%}
        {% set name = lang['name'].items()|first|last -%}
        {% set prefix = '' if lang['url_prefix'] == None else lang['url_prefix'] -%}
        {% set norm_prf = prefix.rstrip('/') -%}
        {# Leave out current language -#}
        {% if (not norm_prf and this._alt != "en") or
                (norm_prf and not norm_prf.endswith(this._alt)) -%}
          {# unelegant way of updating a dict from jinja -#}
          {%- if alts.update({name: norm_prf}) %} {% endif -%}
        {%- endif -%}
        {%- endfor -%}

        {# write out list -#}
        <ul>
        {% for name, url_prefix in alts|dictsort -%}
        <li><a href="{{ url_prefix }}{{ this.path }}">{{ name }}</a></li>
        {% endfor -%}
        </ul><br />
        {# use / for English locale and /alt for the others #}
        {% set prefix = '/' if alt == 'en' else '/%s/' % this.alt -%}
        {# The heading passed to slugify has to exactly match the heading from
          contents/community/. The lektor-headings-anchor plugin uses slugify
          for the anchors. #}
          <div class="help-translation"><p><a 
            href="{{ prefix }}community/index.html#{{ slugify(_('Website Translations')) }}">
                  {{ _('Help translating this website!') }}</a></p>
        </div>
      </div>
      <p>&copy; Copyright {{ get_year() }} by The FreeDict Project.</p>
    </footer>
  </body>
</html>
